package com.wonders.frame.chron.dao.card;


import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.wonders.frame.chron.model.bo.Card;
import com.wonders.frame.core.dao.GenericRepository;

public interface CardDao extends  GenericRepository<Card, Integer>{
	@Query("select a from Card a where a.removed = 0 and a.cardNo =?")
	public List<Card> findByCardNo(String cardNo);
	
	@Transactional  
	@Modifying 
	@Query("update Card a set a.todoItemId=?,a.processInstanceId=?,a.processDefinitionId=?,a.status=? where a.removed = 0 and a.id =?")
	public Integer updateCardById(String todoItemId,String processInstanceId,String processDefinitionId,String status,Integer id);
	
	@Transactional  
	@Modifying 
	@Query("update Card a set a.todoItemId=?,a.status=? where a.removed = 0 and a.id =?")
	public Integer updateCardById(String todoItemId,String status,Integer id);
	
	public int rebindCatalog(Integer pIdNew, List<Integer> cardIds, String code);
	
	public String getSerialNo(String deptId);
	
	public int bindSummary(Integer summaryId, List<Integer> cardIds);
	
	@Transactional  
	@Modifying 
	@Query("update Card set summaryId = null where removed = 0 and summaryId =?")	
	public int unbindSummary(Integer summaryId);
}
	